//
//  Board.h
//  INFSWA02
//
//  Created by Justin van Grootveld on 9/21/11.
//  Copyright 2011 Justinform. All rights reserved.
//

#import <Foundation/Foundation.h>
#import "State.h"

@class MainViewController;
@class Square;
@class Player;
@class Piece;
@class Board;
@class CircularBufferController;
@class Command;

@interface Board : NSObject
{
    Player *_player1;
    Player *_player2;
    Player *_currentPlayer;
    NSInteger _size;
    NSMutableArray *_grid;
    CircularBufferController *_circularBuffer;
}

@property (nonatomic, strong) MainViewController *mainViewController;
@property (nonatomic, readonly) NSInteger size;
@property (nonatomic, readonly) Player *player1;
@property (nonatomic, readonly) Player *player2;
@property (nonatomic, readonly) Player *currentPlayer;
@property (nonatomic, readonly) NSMutableArray *grid;

@property (nonatomic, assign) id<State> currentState;
@property (nonatomic, assign) id<State> noState;
@property (nonatomic, assign) id<State> actionState;

- (void)updateButtonTitles;

- (id)initWithS:(NSInteger)size;
- (BOOL)setPiece: (Piece *)piece atLocationX:(NSInteger)x andY:(NSInteger)y;
- (Square *)squareAtLocationX:(NSInteger)x andY:(NSInteger)y;
- (Square *)squareForPiece:(Piece *)piece;
- (void)print;
- (void)printLocations;

- (void)movePiece:(Piece *)piece toSquare:(Square *)square;

- (void)initPlayersWithNames:(NSString *)player1Name andPlayer2:(NSString *)player2Name;

- (BOOL)isCurrentPlayer:(Player *)player;

- (void)saveState:(Command *)command;
- (void)loadState;
- (BOOL)hasUndoState;

@end
